home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Programming / ace_gpl_release / src_ansi / ace / c / window.c < prev   
Encoding:
C/C++ Source or Header  |  1999-01-05  |  4.5 KB  |  198 lines

  1. /* << ACE >>
  2.  
  3.    -- Amiga BASIC Compiler --
  4.  
  5.    ** Parser: window functions **
  6.    ** Copyright (C) 1998 David Benn
  7.    ** 
  8.    ** This program is free software; you can redistribute it and/or
  9.    ** modify it under the terms of the GNU General Public License
  10.    ** as published by the Free Software Foundation; either version 2
  11.    ** of the License, or (at your option) any later version.
  12.    **
  13.    ** This program is distributed in the hope that it will be useful,
  14.    ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.    ** GNU General Public License for more details.
  17.    **
  18.    ** You should have received a copy of the GNU General Public License
  19.    ** along with this program; if not, write to the Free Software
  20.    ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  21.  
  22.    Author: David J Benn
  23.    Date: 26th October-30th November, 1st-13th December 1991,
  24.    14th,20th-27th January 1992, 
  25.    2nd-17th, 21st-29th February 1992, 
  26.    1st,13th,14th,22nd,23rd March 1992,
  27.    21st,22nd April 1992,
  28.    2nd,3rd,11th,15th,16th May 1992,
  29.    7th,8th,9th,11th,13th,14th,28th,29th,30th June 1992,
  30.    2nd-8th,14th-19th,26th-29th July 1992,
  31.    1st-3rd,7th,8th,9th August 1992,
  32.    6th,7th December 1992,
  33.    24th,26th October 1993,
  34.    15th November 1993,
  35.    30th April 1994
  36.  */
  37.  
  38. #include "acedef.h"
  39.  
  40. /* externals */
  41. extern int sym;
  42. extern int lastsym;
  43.  
  44. /* functions */
  45. void window (void)
  46. {
  47.   int wtype;
  48.  
  49.   /* WINDOW wdw-id[,title],rectangle[,type][,screen-id] 
  50.      WINDOW CLOSE wdw-id
  51.      WINDOW OUTPUT wdw-id 
  52.      WINDOW ON | OFF | STOP
  53.    */
  54.  
  55.   insymbol ();
  56.  
  57.   if (sym == onsym || sym == offsym || sym == stopsym)
  58.     change_event_trapping_status (lastsym);
  59.   else if (sym == closesym)
  60.     wdwclose ();
  61.   else if (sym == outputsym)
  62.     wdwoutput ();
  63.   else
  64.     {
  65.       /* open a window */
  66.       if (make_integer (expr ()) == shorttype)
  67.     make_long ();        /* Wdw-id */
  68.       if (sym != comma)
  69.     _error (16);
  70.       else
  71.     {
  72.       insymbol ();
  73.       if (sym != comma)
  74.         {
  75.           wtype = expr ();
  76.           if (wtype != stringtype)
  77.         _error (4);    /* type mismatch */
  78.         }
  79.       else
  80.         gen ("move.l", "#0", "-(sp)");    /* NULL */
  81.  
  82.       if (sym != comma)
  83.         _error (16);
  84.       else
  85.         {
  86.           insymbol ();
  87.           if (sym != lparen)
  88.         _error (14);
  89.           else
  90.         {
  91.           insymbol ();
  92.           if (make_integer (expr ()) == shorttype)
  93.             make_long ();    /* x1 */
  94.           if (sym != comma)
  95.             _error (16);
  96.           else
  97.             {
  98.               insymbol ();
  99.               if (make_integer (expr ()) == shorttype)
  100.             make_long ();    /* y1 */
  101.               if (sym != rparen)
  102.             _error (9);
  103.               else
  104.             {
  105.               insymbol ();
  106.               if (sym != minus)
  107.                 _error (21);
  108.               else
  109.                 {
  110.                   insymbol ();
  111.                   if (sym != lparen)
  112.                 _error (14);
  113.                   else
  114.                 {
  115.                   insymbol ();
  116.                   if (make_integer (expr ()) == shorttype)
  117.                     make_long ();    /* x2 */
  118.                   if (sym != comma)
  119.                     _error (16);
  120.                   else
  121.                     {
  122.                       insymbol ();
  123.                       if (make_integer (expr ()) == shorttype)
  124.                     make_long ();    /* y2 */
  125.                       if (sym != rparen)
  126.                     _error (9);
  127.                     }
  128.  
  129.                   insymbol ();
  130.  
  131.                   /* optional window type */
  132.                   if (sym == comma)
  133.                     {
  134.                       insymbol ();
  135.                       if (sym != comma)
  136.                     {
  137.                       if (make_integer (expr ()) == shorttype)
  138.                         make_long ();    /* type */
  139.                     }
  140.                       else
  141.                     gen ("move.l", "#-1", "-(sp)");
  142.                     }
  143.                   else
  144.                     gen ("move.l", "#-1", "-(sp)");
  145.  
  146.                   /* optional screen-id */
  147.                   if (sym == comma)
  148.                     {
  149.                       insymbol ();
  150.                       if (sym != comma)
  151.                     {
  152.                       if (make_integer (expr ()) == shorttype)
  153.                         make_long ();    /* scrn-id */
  154.                     }
  155.                       else
  156.                     gen ("move.l", "#0", "-(sp)");
  157.                     }
  158.                   else
  159.                     gen ("move.l", "#0", "-(sp)");
  160.  
  161.                   /* call open-window routine */
  162.                   gen ("jsr", "_OpenWdw", "  ");
  163.                   gen ("add.l", "#32", "sp");
  164.                   enter_XREF ("_OpenWdw");
  165.                   enter_XREF ("_IntuitionBase");
  166.                   enter_XREF ("_GfxBase");
  167.                 }
  168.                 }
  169.             }
  170.             }
  171.         }
  172.         }
  173.     }
  174.     }
  175. }
  176.  
  177. void wdwclose (void)
  178. {
  179.   insymbol ();
  180.   if (make_integer (expr ()) == shorttype)
  181.     make_long ();        /* Wdw-id */
  182.   gen ("jsr", "_CloseWdw", "  ");
  183.   gen ("addq", "#4", "sp");
  184.   enter_XREF ("_CloseWdw");
  185.   enter_XREF ("_IntuitionBase");
  186. }
  187.  
  188. void wdwoutput (void)
  189. {
  190.   insymbol ();
  191.   if (make_integer (expr ()) == shorttype)
  192.     make_long ();        /* Wdw-id */
  193.   gen ("jsr", "_ChangeOutputWdw", "  ");
  194.   gen ("addq", "#4", "sp");
  195.   enter_XREF ("_ChangeOutputWdw");
  196.   enter_XREF ("_IntuitionBase");
  197. }
  198.